<template>
  <div class="dogHouse">
    <h1>狗窝</h1>
    狗狗名字: {{ dogName }}
    <button @click="passNum">向父组件传数据</button>
    <button @click="passFood">向兄弟组件传数据</button>
  </div>
</template>

<script>
import eventBus from "../eventBus/index.js";

export default {
  name: "",
  // 接收父组件传来的值
  props: ["dogName"],
  data() {
    return {
      num: Math.ceil(Math.random() * 10),
    };
  },
  created() {},
  methods: {
    // 向兄弟组件传递 数据
    passFood() {
      eventBus.$emit("onShowFood", "肉骨头");
    },
    // 向父组件传递 数字
    passNum() {
      this.$emit("onPassNum", this.num);
    },
  },
  computed: {},
  watch: {},
  components: {},
};
</script>

<style lang="less" scoped>
</style>
